package cn.com.qingz.modules.user.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;

import cn.com.qingz.modules.system.service.impl.GeneralServiceImpl;
import cn.com.qingz.modules.user.mapper.DesignMapper;
import cn.com.qingz.modules.user.model.Design;
import cn.com.qingz.modules.user.service.UserDesignService;
import cn.com.qingz.modules.user.vo.DesignSearchCondition;

@Service
public class UserDesignServieImpl extends GeneralServiceImpl<Design> implements UserDesignService {

    @Autowired
    private DesignMapper designMapper;

    @Override
    public void doAddOrUpdate(Design design) {
        if (0 == design.getDesignid()) {
            //        	design.setDesignid(ShortUUID.get6Number());
            design.setDesignid(null);
            this.mapper.insert(design);
        } else {
            this.mapper.updateByPrimaryKeySelective(design);
        }
    }

    public PageList<Design> queryForPage(Object condition, int page, int limit) {
        PageList<Design> list = designMapper.queryForPage((DesignSearchCondition) condition, new PageBounds(page, limit));
        return list;
    }

}
